/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ejercicio1;

/**
 *
 * @author user
 */
public class Ejercicio1 {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        boolean[][] figura={
            {false, false, false, false, false, false, false, false, false, false},
            {false, false, true, true, true, true, true, true, false, false},
            {false, false, false, true, true, true, true, true, false, false},
            {false, false, false, false, true, true, true, true, false, false},
            {false, false, false, false, false, true, true, true, false, false},
            {false, false, false, false, false, false, true, true, false, false},
            {false, false, false, false, false, false, false, true, false, false},
            {false, false, false, false, false, false, false, false, false, false}                
        };        
        
        for(int i=0;i<figura.length;i++){
            for(int j=0;j<figura[0].length;j++){
                System.out.print(figura[i][j]+"\t");
            }System.out.println();
        } System.out.println();   
        
        System.out.println("Borde superior: " +BordeSuperior(figura));
        System.out.println("Borde inferior: " +BordeInferior(figura));
        System.out.println("Borde izquierdo: " +BordeIzquierdo(figura));
        System.out.println("Borde derecho: " +BordeDerecho(figura));
    }

    private static int BordeSuperior(boolean[][] figura) {
        int sup;
        int i=0, j=0;
        for(i=0;i<figura.length;i++){
            for(j=0;j<figura[0].length;j++){
                if(figura[i][j]==true){
                    sup=figura.length-i-1;
                    return sup;
                }              
            }
        }        
        return 0;
    }

    private static int BordeInferior(boolean[][] figura) {
        int sup;
        int i=0, j=0;
        for(i=figura.length-1;i>=0;i--){
            for(j=0;j<figura[0].length;j++){
                if(figura[i][j]==true){
                    sup=figura.length-i-1;
                    return sup;
                }               
            }
        }   
        return 0;        
    }

    private static int BordeIzquierdo(boolean[][] figura) {
        int sup;
        int i=0, j=0;
        for(j=0;j<figura[0].length;j++){
            for(i=0;i<figura.length;i++){
                if(figura[i][j]==true){
                    sup=j;
                    return sup;
                }
            }
        }
        
        
        return 0;
    }

    private static int BordeDerecho(boolean[][] figura) {
        int sup;
        int i=0, j=0;
        for(j=figura[0].length-1;j>=0;j--){
            for(i=0;i<figura.length;i++){
                if(figura[i][j]==true){
                    sup=j;
                    return sup;
                }
            }
        }        
        return 0;
    }
}
//prueba1